from appium import webdriver

from page.base import Base
from page.main import Main
# from appium.webdriver.common.touch_action import TouchAction

class App(Base):
    def start(self):
        desired_caps = {}

        desired_caps['platformName'] = 'Android'
        desired_caps['platformVersion'] = '7.1.2'
        desired_caps['deviceName'] = '127.0.0.1:62001'
        desired_caps['appPackage'] = 'com.http.user'
        desired_caps['appActivity'] = '.MainActivity'
        desired_caps['automationName'] = 'Uiautomator2'

        # 输入中文
        desired_caps['unicodeKeyboard'] = True
        desired_caps['resetKeyboard'] = True
        # 是否重置应用 True:不重置 False:重置
        # desired_caps['noReset'] = True
        # 获取driver
        self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
        self.driver.implicitly_wait(10)

        # self.action = TouchAction(self.driver)

        return self

    def main(self):
        return Main(self.driver)
